package com.gxl.butt.DAO.impl;

import com.gxl.butt.DAO.IReportInDayDAO;
import com.gxl.butt.DAO.IbtipDAO;
import com.gxl.butt.domain.BT_Ip;
import com.gxl.butt.domain.ReportInDay;
import org.springframework.stereotype.Repository;

import java.util.List;


/**
 * Created by GUOXIAOLIN on 2018/7/13.
 */
@Repository
public class ReportInDayDAOImpl extends HibernateBaseDao<ReportInDay> implements IReportInDayDAO {

    @Override
    public List<ReportInDay> getOne(Long userid,String inday) {
        String hql = "from " + ReportInDay.class.getName() + " do where  do.userid = " + userid + " and do.inday = '" + inday + "'";
        List<ReportInDay>  reportInDays = this.getListByHql(hql);
        if (reportInDays != null && reportInDays.size() > 0){
            return reportInDays;
        }
        return null;
    }

    @Override
    public Long saveOne(ReportInDay reportInDay) {
        return (Long) this.save(reportInDay);
    }

    @Override
    public void updateOne(ReportInDay reportInDay) {
        this.update(reportInDay);
    }

    @Override
    public List<ReportInDay> getList(Long userid, Long sum) {
        String hql = "select TOP " + sum + " from " + ReportInDay.class.getName() + " do where  do.userid = " + userid + " order by  do.id desc";
        List<ReportInDay>  reportInDays = this.getListByHql(hql);
        if (reportInDays != null && reportInDays.size() > 0){
            return reportInDays;
        }
        return null;
    }
}
